<?php

class MemberModel extends Model {
	/**
	 * 自动验证规则
	 * @var array
	 */
	protected $_validate = array(
			array( 'name', 'require', '会员姓名不能为空' ),
			);
	
	/**
	 * 获取成员
	 * @param string|array $condition 查询条件
	 * @param string $limit 显示条数
	 * @param string $order 排序
	 */
	public function getMembers($condition='', $limit='', $order=''){
		$members = $this->where($condition)->limit($limit)->order($order)->select();
		foreach($members as $key=>$member){
			$members[$key]['avatar'] = file_exists($member['avatar'])?$member['avatar']:C('DEFAULT_AVATAR');
			$members[$key]['gender_text'] = $member['gender'] == 1 ? '男' : '女';
			$members[$key]['role_text']   = $member['role'] == 1 ? '老师' : '学生';
			$members[$key]['recommend_text']   = $member['recommend'] == '1' ? '是' : '否';
		}
		return $members;
	}
	
	
}